<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移除事件监听器</title>
    <style>
        .wrapper {
            border: 1px solid blue;
        }
    </style>
</head>

<body>

    <div class="wrapper">
        <button type="button">移除事件监听器</button>
    </div>

    <script>
        (() => {
            let w = document.querySelector('.wrapper');

            const useCapture = false; // true | false ;

            const mouseOver = function(event) {
                event.preventDefault();
                event.stopPropagation();
                let target = event.target || event.srcElement;
                target.style.background = '#dfdfdf';
            }

            w.addEventListener('mouseover', mouseOver, useCapture);

            const mouseOut = function(event) {
                event.preventDefault();
                event.stopPropagation();
                let target = event.target || event.srcElement;
                target.style.background = '#ffffff';
            }

            w.addEventListener('mouseout', mouseOut, useCapture);

            let btn = document.querySelector('.wrapper>button');
            const click = function(event) {
                event.preventDefault();
                event.stopPropagation();

                let target = event.target || event.srcElement;
                let parent = target.parentElement;

                parent.removeEventListener('mouseover', mouseOver, useCapture);
                parent.removeEventListener('mouseout', mouseOut, useCapture);
                target.removeEventListener('click', click, useCapture);
            }
            btn.addEventListener('click', click, useCapture);
        })();
    </script>

</body>

</html>